microbit = codesters.Microbit()
microbit.show_string("hello")
stage.set_background("soccerfield")
sprite = codesters.Sprite("athlete2")
sprite.move_down(150)
def button_a():
sprite.move_left(50)
microbit.event_button_a(button_a)
def button_b():
sprite.move_right(50)
microbit.event_button_b(button_b)
ball = codesters.Sprite("soccerball")
ball.set_x_speed(5)
t = codesters.Teacher()
try:
function = t.find_function('set_y_speed')
tval1 = function[0][1]
except:
tval1 = "DNE"
t1 = TestObjective()
t1.add_success(tval1 != "DNE", "Great Job!")
t1.add_failure(tval1 == "DNE", "Did you add the Set y Speed command?")
t2 = TestObjective()
t2.add_success("ball.set_y_speed" in tval1, "Great Job!")
t2.add_failure("sprite.set_y_speed" in tval1 or "ball.set_y_speed" not in tval1, "Did you change the name from sprite to ball?")
t2.add_failure(tval1 == "DNE", "Did you delete the Set y Speed command?")
tester = TestManager()
tester.add_test_list([t1, t2])
tester.run_tests()
tester.display_first_feedback()
-
Run Code
-
Activity Submitted!
Submit Work
-
Next Activity
-
Stop Running Code
-
Show Chart
-
Show Console
-
Reset Code Editor
-
Codesters How To (opens in a new tab)